//
//  SetInviteCodeVM.swift
//  LeTu
//
//  Created by gy on 2023/12/20.
//

import Foundation

class SetInviteCodeVM {
    
    /// 设置邀请码
    func setInvite(params: [String: Any], completeHandle: @escaping NetworkRequestHandle) {
        
        apiProvider.request(api: .setInviteCode(params: params)) { json, jsonArr, code in
            MYLog("设置邀请码：",json)
            
            var dialog = DialogMessage()
            
            guard code == 200, let pm = Mapper<ResponseModel>().map(JSON: json) else { return completeHandle(dialog) }
            dialog.code = pm.code
            dialog.message = pm.msg
            completeHandle(dialog)
            
        } failureHandler: { error in
            completeHandle(DialogMessage())
        }
                
    }
    
}

